/*
 * @Author: szx
 * @Date: 2021-12-23 13:50:57
 * @LastEditTime: 2021-12-23 13:59:54
 * @Description:
 * @FilePath: \leetcode\100-199\112\112.js
 */

/**
 * @param {TreeNode} root
 * @param {number} targetSum
 * @return {boolean}
 */
var hasPathSum = function (root, targetSum) {
    if (!root) return false;
    if (!root.left && !root.right) {
        return targetSum == root.val;
    }
    return hasPathSum(root.left, targetSum - root.val) || hasPathSum(root.right, targetSum - root.val);
};
